Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming
Foundations of 4GL classes
Classes are supported by a number of specific constructs within the language. First and foremost is the new
CLASSstatement, which can be used to define user-defined types in Progress. Classes defined by theCLASSstatement contain both state and behavior.Progress class definitions support inheritance of state and behavior from one class to another. That is, you can define a new class with reference to an existing class so that the state and behavior of the existing class appear to be part of the new class. At the same time, you can define additional state and behavior in the new class that does not exist in the inherited class. Thus, multiple classes can be related to one another in a hierarchy formed by their defined inheritance relationships. For more information on inheritance, see the "Inheritance" section.
Classes can also implement one or more interfaces, each of which is defined by the
INTERFACEstatement. An interface specifies a common public mechanism to access behavior that one or more classes can define and that these classes do not inherit from a common class. Interfaces allow you to more easily define and manage common behavior that might be implemented differently in different objects and for different purposes. An interface also represents a user-defined class type, but never contains an implementation of that type. Only a class can implement the class type specified by an interface. However, both a class and an interface can be used to specify a class type in the language anywhere that a type can be specified. In this respect, the support for classes in the Progress 4GL is very similar to classes in Java and other object-oriented programming languages.The
CLASSorINTERFACEstatement is always the first statement in a class. This identifies the source code file as representing a class and not a more traditional Progress procedure. Within a class, there are several language statements that are distinctive to classes and which can be used only within them. On the other hand, you can use the vast majority of Progress 4GL syntax within classes, and for the most part, you can use them in exactly the same way as they are used in procedures.This means that there is a dichotomy in how you must think about classes in Progress. On the one hand, there is a clear and absolute distinction between classes and procedures, and the compiler can tell from the very first statement in a source file which kind of object it is dealing with. On the other hand, the majority of the programming that you do within a class can be very much the same as within a procedure. This means that if you are already thoroughly familiar with how to program Progress procedures, programming with classes can quickly become as familiar and natural.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |